﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Jxym.DBUtility;
using Jxym.wlkc2011.Module.CMS.MODEL;


namespace Jxym.wlkc2011
{
    public partial class zj : System.Web.UI.UserControl
    {
        private string _href = "#";
        private string _title = "未命名";
        public int MyContentClassID
        {
            get { return _myContentClassID; }
            set { _myContentClassID = value; }
        }
        public string MyTitle
        {
            get { return _title; }
            set { _title = value; }
        }
        public string MyHref
        {
            get { return _href; }
            set { _href = value; }
        }
        public int TopN
        {
            get;
            set;
        }
        public string _siteName { get; set; }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Params["siteName"] != null)
            {
                _siteName = Request.Params["siteName"];
            }

            MsSqlDal<Cms_Site_ContentClass> cscc = new MsSqlDal<Cms_Site_ContentClass>();

            IList<Cms_Site_ContentClass> csccList = cscc.GetList("siteName='" + _siteName + "'", null, "", 0);

            foreach (Cms_Site_ContentClass csccInfo in csccList)
            {
                MsSqlDal<Cms_ContentClass> ccc = new MsSqlDal<Cms_ContentClass>();

                Cms_ContentClass cccInfo = ccc.GetModel(csccInfo.ContentClassID);

                if (cccInfo != null)
                {
                    if (cccInfo.Title == _title)
                    {
                        IList<Cms_ContentClass> cccList = ccc.GetList("ParentID=" + cccInfo.ID, null, "", TopN);

                        if (cccList != null)
                        {
                            Repeater1.DataSource = cccList;
                            Repeater1.DataBind();
                        }

                        if (TopN > 0)
                        {
                            more.Visible = true;
                        }
                        else
                        {
                            more.Visible = false;
                        }
                    }
                }
            }
        }

        public int _myContentClassID { get; set; }
    }
}